package reflect;

import java.lang.reflect.Method;

/**
 * @author Administrator
 * @Description
 * @date 2022/5/23 14:01
 **/
public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.say("大家好");


        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();
        Method method = cls.getMethod("say", String.class);
        method.invoke(o,"哈哈哈哈");

        Method method1 = cls.getMethod("say", String.class, int.class);
        method1.invoke(o,"hello", 4);
    }
}
